# cat /etc/alpine-release 3.19.1
FROM node:20.11.1-alpine
MAINTAINER chris<kengric@126.com>
ARG Dir_Work=/opt
ARG Project=book-starter
ARG Dir_Project=$Dir_Work/$Project
ARG DIR_Project_Web=$Dir_Project/app/web
ARG Yaml=application.yaml
WORKDIR $Dir_Work
EXPOSE 555
# install openjdk8 & git
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add openjdk8 && java -version
RUN apk add git && git -v

# run
RUN git clone https://gitee.com/ceogo/my-sample.git $Project
WORKDIR $DIR_Project_Web
RUN npm config set registry http://mirrors.cloud.tencent.com/npm/ --global
RUN npm install
RUN npm run build
WORKDIR $Dir_Project/dist
RUN cp $Dir_Project/src/main/resources/$Yaml .
RUN echo "  mvc: " >> $Yaml  \
    && echo "    static-path-pattern: /**" >> $Yaml  \
    && echo "  resources:" >> $Yaml  \
    && echo "    static-locations: file:${DIR_Project_Web}/dist,classpath:/static" >> $Yaml
# argument is invalid in cmd
ENV ENV_YAML $Dir_Project/dist/$Yaml
CMD java -jar book-starter-1.0.jar --spring.config.location=$ENV_YAML
